package net.meblabs.commons.progress;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

public class ProgressRegistry {

	private static AtomicLong idGen = new AtomicLong(0);
	private static Map<Long, Progress> progresses = new HashMap<Long, Progress>();

	public static Progress createProgress() {
		Progress progress = new ProgressImpl(idGen.getAndIncrement());
		progresses.put(progress.getId(), progress);
		return progress;
	}

	public static ComplexProgress createComplexProgress() {
		ComplexProgress monitor = new ComplexProgressImpl(idGen.getAndIncrement());
		progresses.put(monitor.getId(), monitor);
		return monitor;
	}

	public static Progress getProgress(Long id) {
		return progresses.get(id);
	}
}
